﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using guardaLinks.Logica;

namespace guardaLinks.Presentacion
{
    /// <summary>
    /// Lógica de interacción para crearUsuario.xaml
    /// </summary>
    public partial class crearUsuario : Window
    {
        public crearUsuario()
        {
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            menu abrirMenu = new menu();
            abrirMenu.Show();
            this.Close();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            MainWindow abrirMain = new MainWindow();
            abrirMain.Show();
            this.Close();
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            if (tbuser.Text != "")
            {
                if (tbpass.Text != "")
                {
                    if (tbpass.Text == tbpassc.Text)
                    {
                        CrearUsuario cu = new CrearUsuario();
                        cu.guardarUsuario(tbuser.Text, tbpass.Text);
                        MessageBox.Show("Datos guardados Satisfactoriamente");
                        MainWindow abrirMain = new MainWindow();
                        abrirMain.Show();
                        this.Close();


                    }
                    else
                    {
                        MessageBox.Show("Las contraseñas no coinciden");
                        tbpass.Text = "";
                        tbpassc.Text = "";
                        tbpass.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Falta ingresar contraseñas");
                    tbpass.Focus();
                }

            }
            else 
            {
                MessageBox.Show("Falta ingresar un nombre de usuario");
            }


        }

        private void TextBox_TouchLeave_1(object sender, TouchEventArgs e)
        {
            
        }
    }
}
